package com.google.code.garbagecan.jbossasstudy.stateless;

import java.io.IOException;
import java.io.PrintWriter;

import javax.inject.Inject;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


@SuppressWarnings("serial")
@WebServlet("/stateless/CalculatorServlet")
public class CalculatorServlet extends HttpServlet {

	@Inject
	Calculator calculator;
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		PrintWriter writer = resp.getWriter();
		
		writer.println("calculator.add(4, 6): " + calculator.add(4, 6));
		writer.println("calculator.subtract(4, 6): " + calculator.subtract(4, 6));
		writer.println("calculator.multiply(4, 6): " + calculator.multiply(4, 6));
		writer.println("calculator.divide(12, 6): " + calculator.divide(12, 6));
		writer.println("calculator.remainder(46, 6): " + calculator.remainder(46, 6));

		writer.close();
	}
}
